SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE PROCEDURE [dbo].[ServiceTypeIsExist]
    @Name VARBINARY(MAX) ,
    @Id UNIQUEIDENTIFIER
AS 
    BEGIN
        IF ( @Id = NULL ) 
            BEGIN
                SELECT  COUNT(*)
                FROM    ServiceType
                WHERE   Name = @Name
                        AND DELETED = 0
            END
        ELSE 
            BEGIN
                SELECT  COUNT(*)
                FROM    ServiceType
                WHERE   Name = @Name
                        AND Id != @Id
                        AND DELETED = 0
            END
    END
GO
